package com.springcloudalibaba.baseredis.demo;

import java.util.Random;

/**
 * @描述: jetcache官网：https://github.com/alibaba/jetcache
 * @作者: lixing
 * @日期 2021/7/17 11:05
 */
public class JetCacheDemo {
    /**
     * POM文件新增依赖：
     * <dependency>
     *    <groupId>com.alicp.jetcache</groupId>
     *    <artifactId>jetcache-starter-redis-lettuce</artifactId>
     * </dependency>
     *
     * 启动类新增注解：
     *  @EnableMethodCache(basePackages = "com.springcloudalibaba")
     *  @EnableCreateCacheAnnotation
     *
     * 配置文件中 新增 jetcache 配置
     * jetcache:
     *   # 统计间隔，0表示不统计
     *   statIntervalMinutes: 10
     *   # 是否把cacheName作为远程缓存key前缀
     *   areaInCacheName: false
     *   # 本地缓存
     *   local:
     *     default:
     *       type: linkedhashmap
     *       keyConvertor: fastjson
     *       limit: 100
     *   # 远程缓存
     *   remote:
     *     default:
     *       type: redis.lettuce
     *       keyConvertor: fastjson
     *       uri: redis://${spring.redis.password}@${spring.redis.host}:${spring.redis.port}/${spring.redis.database}
     */

//    // 有效期 60 秒
//    @Cached(name = SysKeyConstant.PROJECTNAME + ":" + SysKeyConstant.JETCAHCE + ":" + JetCacheConstant.GETUSERPWD + ":", key = "#baseLoginUserInfo.account", expire = 1000 * 60, timeUnit = TimeUnit.MILLISECONDS, cacheType = CacheType.REMOTE)
//
//    // 默认 50秒刷新一次，如果 60 秒内没有被访问则停止刷新
//    @CacheRefresh(refresh = 1000 * 50, stopRefreshAfterLastAccess = 1000 * 60, timeUnit = TimeUnit.MILLISECONDS)
//    User getUser(BaseLoginUserInfo baseLoginUserInfo);
//
//    @CacheUpdate(name=SysKeyConstant.PROJECTNAME + ":" + SysKeyConstant.JETCAHCE + ":" + JetCacheConstant.GETUSERPWD + ":", key="#baseLoginUserInfo.account", value="#baseLoginUserInfo")
//    void updateUser(BaseLoginUserInfo baseLoginUserInfo);
//
//    @CacheInvalidate(name=SysKeyConstant.PROJECTNAME + ":" + SysKeyConstant.JETCAHCE + ":" + JetCacheConstant.GETUSERPWD + ":", key="#account")
//    void deleteUser(String account);

    /**
     *
     */
    public static void main(String[] args) {
        System.out.println(5 + new Random().nextInt(5));
    }
}
